<?php
    //ini_set('display_errors',1);
    include ("lib_db.php");
	include("function.php");
	include("config.php");
	if(!isset($_SESSION)){ session_start();}
if(!isset($_SESSION['user'])){
header('location:login.php');
exit();
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xlmns="http://www.w3.org/1999/xhtml">
<head><?php include("view/head.php");?></head>

<body>
<div class="wrapper">
	<div class="header"><?php include ("view/header.php");?></div>
	<div class="clear"></div>
	<div class="content">
		<div class="menu"><?php include("view/menu.php");?></div>
		<div class="center_content">
			<div class="left_content"> <?php include ("view/left_content.php");?></div>
			
<script>
    $(document).ready(function(){
        $("#nhomsp").change(function(){
           var gid = $(this).val();//alert(gid);
           $("#loaisp").load("load_cproduct.php?gid="+gid);
           $("#loaisp").change(function(){
           var cid = $(this).val();//alert(cid);
           $("#dongsp").load("load_tproduct.php?cid="+cid); 
        }); 
        });
    });
</script>
<?php 
 if(isset($_POST['insert'])){
    if(isset($_REQUEST['tensach'])){
        if(isset($_REQUEST['nsp'])){$idCategory=$_REQUEST['nsp'];}
        $tensach=$_REQUEST['tensach'];
        $tacgia=$_REQUEST['tacgia'];
		$dichgia=$_REQUEST['dichgia'];
        $hinthucbia=$_REQUEST['hinthucbia'];
		$nhaxuatban=$_REQUEST['nhaxuatban']; 
		$sotrang=$_REQUEST['sotrang'];
		$trongluong=$_REQUEST['trongluong'];
		$giaban=$_REQUEST['giaban'];
		$giabia=$_REQUEST['giabia'];
		$kichco=$_REQUEST['kichco'];
		$giamgia=$_REQUEST['giamgia'];
		$soluong=$_REQUEST['soluong'];
		$mota=$_REQUEST['mota'];
		$image=$_REQUEST['image'];
			 
		
        $sql="insert into book (Name, Author, Translator, Paperboard, Size, Publisher, PageNumber, Weight, SalePrice, CoverPrice, Number, SaleOff, ImgCover, Description, idCategory)
		values ('{$tensach}','{$tacgia}','{$dichgia}', '{$hinthucbia}', '{$kichco}', '{$nhaxuatban}', '{$sotrang}', '{$trongluong}', '{$giaban}', '{$giabia}', '{$soluong}', '{$giamgia}', '{$image}', '{$mota}', '{$idCategory}')";
        $query=exec_update($sql);//echo "<pre>";print_r($query);echo "</pre>";exit();
		header("location:index.php");
    }
 }

 ?>  
			<div class="right_content">
				<h2>Thêm sản phẩm</h2>
                <form action="insert_product.php" method="POST">              
    				<table>
                       <tr class="title">
                            <td><span>Tên nhóm sản phẩm:</span></td>
                            <td><select id="nhomsp" class="nsp" name="nsp" style="width: 250px;"><?php echo glist_option();?></select></td>
                        </tr> 

                        <tr class="title">
                            <td><span>Tên Sách:</span></td>
                            <td><input type="text" value="" style="width:240px" name="tensach"></td>
                        </tr>
						<tr class="title">
                            <td><span>Tắc Giả:</span></td>
                            <td><input type="text" value="" style="width:240px" name="tacgia"></td>
                        </tr><tr class="title">
                            <td><span>Dịch Giả:</span></td>
                            <td><input type="text" value="" style="width:240px" name="dichgia"></td>
                        </tr><tr class="title">
                            <td><span>Hình Thức Bìa:</span></td>
                            <td><input type="text" value="" style="width:240px" name="hinthucbia"></td>
                        </tr>
                     
						<tr class="title">
                            <td><span>Nhà xuất bản:</span></td>
                            <td><input type="text" value="" style="width:240px" name="nhaxuatban"></td>
                        </tr>
						<tr class="title">
                            <td><span>Số Trang:</span></td>
                            <td><input type="text" value="" style="width:240px" name="sotrang"></td>
                        </tr>
						<tr class="title">
                            <td><span>Trọng Lượng:</span></td>
                            <td><input type="text" value="" style="width:240px" name="trongluong"></td>
                        </tr>
						<tr class="title">
                            <td><span>Giá Bán:</span></td>
                            <td><input type="text" value="" style="width:240px" name="giaban"></td>
                        </tr>
						<tr class="title">
                            <td><span>Giá Bìa:</span></td>
                            <td><input type="text" value="" style="width:240px" name="giabia"></td>
                        </tr>
							<tr class="title">
                            <td><span>Kích cỡ:</span></td>
                            <td><input type="text" value="" style="width:240px" name="kichco"></td>
                        </tr>
						<tr class="title">
                            <td><span>Giảm giá:</span></td>
                            <td><input type="text" value="" style="width:240px" name="giamgia"></td>
                        </tr>
						
						
						<tr class="title">
                            <td><span>Sô lượng:</span></td>
                            <td><input type="text" value="" style="width:240px" name="soluong"></td>
                        </tr>
						
                        <tr class="title">
                            <td><span>Mô tả sản phẩm:</span></td>
                            <td><textarea style="background-color:#E0E0EB;width: 250px; height: 80px;" name="mota"></textarea></td>
                        </tr>
						
                         
                        <tr class="title">
                            <td><span>Hình ảnh sản phẩm:</span></td>
                            <td><input type="file" name="image" value="Choose File" style="width:244px" /></td>
                        </tr>
                        
                        <tr class="value">
                            <td></td>
                            <td>
                                <input type="reset" value="Nhập lại" name="reset"/>
                                <input type="submit" value="Thêm" name="insert"/>
                            </td>
                        </tr>
                    </table>
                </form>
		  </div>
		</div>
	</div>
	<div class="clear"></div>
	<div class="footer">
		<div class="left_ft">
			<span>IN ADMIN PANEL | Powered by</span>
			<a href="http://indeziner.com">INDEZINER</a>
		</div>
		<div class="right_ft">
			<a href="http://indeziner.com"><img border="0" title="" alt="" src="images/indeziner_logo.gif"></a>
		</div>
	</div>
</div>
</body>
</html>
<?php } ?>